var e = require;
var t = module;
var o = exports;
var n,
    i =
        (this && this.__extends) ||
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            n(e, t);
            function o() {
                this.constructor = e;
            }
            e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o());
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, o, n) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, o, n);
            else
                for (var c = e.length - 1; c >= 0; c--)
                    (i = e[c]) && (a = (r < 3 ? i(a) : r > 3 ? i(t, o, a) : i(t, o)) || a);
            return r > 3 && a && Object.defineProperty(t, o, a), a;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = cc._decorator,
    c = a.ccclass,
    u = a.property,
    s =
        (a.menu,
        (function () {
            function e() {
                this.tag = 0;
                this.delay = 1;
            }
            r([u()], e.prototype, "tag", void 0);
            r([u()], e.prototype, "delay", void 0);
            return r([c("UIAniDelayPlay")], e);
        })()),
    p = (function (e) {
        i(t, e);
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            t.isPlayAnimation = !0;
            t.isPlayAllChildren = !1;
            t.show_action_tag = 0;
            t.close_action_tag = 1;
            t.hide_action_tag = 2;
            t.redisplay_action_tag = 3;
            t.enable_delay_play = [];
            return t;
        }
        t.prototype.onEnable = function () {
            var e = this;
            this.enable_delay_play.forEach(function (t) {
                e.scheduleOnce(function () {
                    this.showActionByTag(t.tag);
                }, t.delay);
            });
            this.enable_delay_play = [];
        };
        t.prototype.show = function (e) {
            return this.showActionByTag(this.show_action_tag, e);
        };
        t.prototype.close = function (e) {
            return this.showActionByTag(this.close_action_tag, e);
        };
        t.prototype.hide = function (e) {
            return this.showActionByTag(this.hide_action_tag, e);
        };
        t.prototype.redisplay = function (e) {
            return this.showActionByTag(this.redisplay_action_tag, e);
        };
        t.prototype.showActionByTag = function (e, t) {
            void 0 === t && (t = null);
            if (this.isPlayAnimation) {
                var o,
                    n = 0;
                o = this.isPlayAllChildren
                    ? this.getComponentsInChildren(cc.Animation)
                    : this.getComponents(cc.Animation);
                for (var i in o) {
                    var r = o[i],
                        a = r.getClips();
                    if (a.length > e && null != a[e]) {
                        var c = r.play(a[e].name),
                            u = c ? c.duration / c.speed + c.delay : 0;
                        n = Math.max(u, n);
                    }
                }
                if (n > 0 && t) {
                    this.scheduleOnce(t, n);
                    return !0;
                }
            }
            return !1;
        };
        r([u({tooltip: "通过animation替代Action,对应tag为animation数组编号"})], t.prototype, "isPlayAnimation", void 0);
        r(
            [
                u({
                    tooltip: "播放所有子节点对应的编号animation, 若要单独设置其他时机播放的需放数组其他位置",
                    visible: function () {
                        return this.isPlayAnimation;
                    }
                })
            ],
            t.prototype,
            "isPlayAllChildren",
            void 0
        );
        r([u({displayName: "showTag"})], t.prototype, "show_action_tag", void 0);
        r([u({displayName: "closeTag"})], t.prototype, "close_action_tag", void 0);
        r([u({displayName: "hideTag"})], t.prototype, "hide_action_tag", void 0);
        r([u({displayName: "redisplayTag"})], t.prototype, "redisplay_action_tag", void 0);
        r([u({type: [s], displayName: "延迟显示"})], t.prototype, "enable_delay_play", void 0);
        return r([c], t);
    })(cc.Component);
o.default = p;
p.default = p;
t.exports = p;
